package vn.edu.saigontech.ncms.service.impl;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import vn.edu.saigontech.ncms.model.system.Parameter;
import vn.edu.saigontech.ncms.service.ParameterService;

public class ParameterServiceImpl extends HibernateGenericService<Parameter, Long> implements ParameterService {

	@Override
	public Parameter find(String key) {
		Criteria criteria = this.createCriteria();
		criteria.add(Restrictions.eq("name", key));
		return (Parameter) criteria.uniqueResult();
	}

	@Override
	public Double findNumber(String key) {
		return Double.valueOf(this.find(key).getValue());
	}

	@Override
	public String findText(String key) {
		return this.find(key).getValue();
	}
	
	@Override
	public String findTitle(String key) {
		return this.find(key).getComment();
	}
}